﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using CodingBlog.Core.Model;
using CodingBlog.Core.Service;

namespace CodingBlog.UI.Controllers
{
    public class PostController : Controller
    {
        public ActionResult List()
        {
            var service = new BlogService();

            var count = service.GetBlogsCount();
            Blog blog;

            if (count == 0)
            {
                var fakeBlog = new Blog()
                                   {
                                       Title = "CodingBlog!",
                                       SubTitle = "Video blog programistyczny",
                                       CreationDate = DateTime.Now
                                   };
                blog = service.CreateBlog(fakeBlog);
            }
            else
            {
                blog = service.GetDefaultBlog();
            }

            return View(blog);
        }
    }
}
